import request from "@/utils/request";
import type { AttrList, GetAttrListParams, AttrItem } from "./model/attrModel";

enum Api {
  getAttrInfoListUrl = "/admin/product/attrInfoList",
  postAttrInfoListUrl = "/admin/product/saveAttrInfo",
  deleAttrInfoListUrl = "/admin/product/deleteAttr",
}

export const getAttrInfoListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrListParams) => {
  return request.get<any, AttrList>(
    Api.getAttrInfoListUrl + `/${category1Id}/${category2Id}/${category3Id}`
  );
};

//添加属性接口函数
export const postAttrInfoListApi = (data: AttrItem) => {
  return request.post<any, null>(Api.postAttrInfoListUrl, data);
};

// 删除属性接口函数
export const deleAttrInfoListApi = (id: number) => {
  return request.delete<any, null>(Api.deleAttrInfoListUrl + `/${id}`);
};
